#ifndef QPROPERTYCORE_H
#define QPROPERTYCORE_H

#include "sharedlibglobal.h"

#include <QObject>
#include <QList>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>

namespace SHAREDLIB
{

    class QAbstractProperty;
    class QProjectHost;
    class QUserManager;
    class QLanguageManager;
    class QPageManager;
    class QAbstractHost;
    class QMemeryManager;
    class QPageInfo;

    class SHAREDLIB_EXPORT QProjectCore : public QObject
    {
        Q_OBJECT
    protected:
        explicit QProjectCore(QObject *parent = 0);
    public:
        ~QProjectCore();


        void    open(const QString &filePath);
        void    create(const QString & path,const QString &name);

        QVariant getPropertyValue(const QString &name);

        static  QProjectCore* getCore();
        static  void           releaseCore();


        QUserManager*   userManager();
        QLanguageManager* languageManager();
        QPageManager*       pageManager();
        QMemeryManager*     memeryManager();

        QAbstractHost   *host();

        void            addNewForm(const QString &name,const QString& base_file="");
        void            addNewDialog(const QString &name,const QString& base_file="");
        void            addNewKeyboard(const QString& name,const QString& base_file);
        void              addNewPage(const QString &type,const QString &name,const QString &base_file);
    protected:
        friend class QProjectHost;
    protected:
        void            loadProject(QXmlStreamReader *r);
        void            saveProject(QXmlStreamWriter *w);
    signals:
        void            projectOpen();
        void            projectClosed();
        void            projectSave();
    public slots:
        void    closed();
        void    save();
        void    pageAdd(SHAREDLIB::QPageInfo* info);
        void    pageDel(SHAREDLIB::QPageInfo* info);
        void    languageAdd(QObject* obj,int index);
        void    languageDel(QObject* obj);
        void    languageNameChanged(const QString &old,const QString& now);
        void    userAdd(QObject* obj,int index);
        void    userDel(QObject* obj);
        void    userNameChanged(const QString& old,const QString& now);
    protected:
        QUserManager        *m_userManager;
        QLanguageManager    *m_languageManager;
        QPageManager        *m_pageManager;
        static QProjectCore    *m_core;
        QProjectHost            *m_host;
        bool                    m_isOpen;
        QString                 m_projectPath;
        QMemeryManager*         m_memeryManager;
    };

}

#endif // QPROPERTYCORE_H
